<?php
/**

 *
 * @package Elgg
 * @subpackage Core
 *
 */

global $CONFIG;


$limit = 99999;

$options = array(	//'metadata_name_value_pairs'	=>	array('product_type_id' => 2),
						'types'				=>	"object",
						'subtypes'			=>	"category",												
						'limit'				=>	$limit,
						
					);
		$cats = elgg_get_entities_from_metadata($options);

		/*
		set_context('search');
		
		if(cats){
			if(isloggedin()){

				$path = $CONFIG->wwwroot."pg/{$CONFIG->pluginname}/" . $_SESSION['user']->username . "/all";

			} else{
				$path = "http://localhost/elgg_7/pg/socialcommerce/all";
			}
			
			$x = "<a href=" . $path . ">Categories</a>";
			$area1 .= $x;

			$fullview = false;
			*/
			/*
			foreach($cats as $cat){
				//print_r ("entityview-".$cat->view."-end");
				if(!isloggedin()){
					$d_area .= elgg_view_entity($cat, $fullview);
				}
				else{
					$d_area .='<div class="catloggedout">'.$cat->title.'</div>';
				}

			}
			*/
			
			//set_context('socialcommerce');
			//$area1 .= $d_area;
			//$cate_text = elgg_echo('category:all');
			
	
			foreach ($cats as $cat){
				$list_items .= "<li><a href='".$CONFIG->url."pg/".$CONFIG->pluginname."/".$cat->guid."/product_cate'>".$cat->title."</a></li>";
			}
			
		
			
			$category_area = "<ul>".$list_items."</ul>";
			
			
			/*
			$category_area = <<<EOF

				
				<div style="border: 1px solid #FFF; padding: 2px; background: #EEEEEE; -moz-border-radius:2px; ">

					<table border="0" cellspacing="0" cellpadding="2" width="100%" >
						<tr>
							<td><a href="javascript: void(0);" onclick="toggle(divec_link, 'divec');" style=" text-decoration: none; color: #333; font-weight: bold; " >{$cate_text} </a></td>
							<td align="right">
								<a title="show/hide" id="divec_link" href="javascript: void(0);" onclick="toggle(this, 'divec');"  style="text-decoration: none; color: #333; font-weight: bold; ">+</a>
							</td>
						</tr>
					</table> 

					<div id="divec" style="padding: 3px; display: none; color: #888; font-family: 'arial'">

						<div>{$d_area}</div>
						
					</div>
				</div>
				
EOF;
		}
		
		//set_context('socialcommerce');
*/
echo $category_area;

